package dao

import (
	"context"
	"sale-admin/internal/dal"
	"sale-admin/internal/models"
)

type GoodsClass struct{}

func (GoodsClass) List(ctx context.Context, query *dal.Query, merchantID, classID string, page, limit int) (res []*models.MaGoodsClass, count int64, err error) {
	gc := query.MaGoodsClass
	tx := gc.WithContext(ctx)
	if merchantID != "" {
		tx = tx.Where(gc.MerchantID.Eq(merchantID))
	}
	if classID != "" {
		tx = tx.Where(gc.ClassID.Eq(classID))
	}
	res, count, _ = tx.FindByPage(Offset(page, limit))
	return
}
